feat(codegen): auto-generate docs with dot-notation, clean types, --no-tty, and backend-default awareness#786
Merged
pyramation merged 3 commits intomainfrom Mar 12, 2026
Conversation
… TypeRegistry threading, and --no-tty docs
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…ted docs Fields that are NON_NULL in GraphQL but have backend-provided defaults are now correctly shown as optional in all generated docs: - README: separate 'Required create fields' and 'Optional create fields (backend defaults)' sections - AGENTS.md: bracket notation [--field <value>] for optional, (optional, has backend default) labels - MCP tools: required array only includes truly required fields - Skills: bracket notation in usage and examples Applies to all 8 doc generators (4 single-target + 4 multi-target). Exports getFieldsWithDefaults() and resolveInnerInputType() from table-command-generator.ts for reuse in docs-generator.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(codegen): auto-generate docs with dot-notation, clean types, --no-tty, and backend-default awareness
Summary
Updates the codegen docs generators so that generated agent skills, READMEs, and MCP tool definitions automatically reflect INPUT_OBJECT dot-notation flattening, clean scalar type names,
--no-ttynon-interactive mode, and correct required/optional status based on backend-provided defaults — no hand-editing of skill files needed.Core change: Added
flattenArgs(args, registry?)andresolveInputFields()helpers indocs-utils.tsthat resolve INPUT_OBJECT types from theTypeRegistry(sinceCleanTypeRefintentionally omitsinputFieldsto avoid circular references). All 8 docs generator functions (generateReadme,generateAgentsDocs,getCliMcpTools,generateSkills+ their multi-target variants) now accept an optionalTypeRegistryand pass it through toflattenArgs.Before:
csdk sign-in --input <value>After:
csdk sign-in --input.clientMutationId <value> --input.email <value> --input.password <value> --input.rememberMe <value> ...Also adds
--no-ttydocumentation sections to all generated READMEs and SKILL.md files.Updates since last revision
Backend-default awareness in docs: Fields with backend-provided defaults (NON_NULL in GraphQL schema but nullable in the CREATE input type, or having an explicit
defaultValuefrom introspection) are now correctly shown as optional rather than required in all generated docs. This is accomplished by exportinggetFieldsWithDefaults()andresolveInnerInputType()fromtable-command-generator.tsand calling them in all 8 doc generator functions.Applied across all doc types:
Required create fieldsandOptional create fields (backend defaults)sections[--field <value>]for optional fields +(optional, has backend default)labels on editable field listsrequiredarray ininputSchemaonly includes truly required fields; omitted entirely when all fields have defaults[--field <value>]in both usage and example sectionsExample (view-grant create):
csdk view-grant create --databaseId <value> --viewId <value> --granteeName <value> --privilege <value> --withGrantOption <value> --isGrant <value>csdk view-grant create --viewId <value> --granteeName <value> --privilege <value> [--databaseId <value>] [--withGrantOption <value>] [--isGrant <value>]Clean type names: Added
cleanTypeName()helper that strips theConstructiveInternalTypeprefix from custom scalar types in generated docs. Applied across all 11 occurrences off.type.gqlTypeindocs-generator.ts(README tables, AGENTS.md field lists, MCP tool props) and ingetScalarTypeName()for flattened args.Email,Hostname,Image,Url,Origin,AttachmentConstructiveInternalTypeEmail— After:EmailFiles changed (source):
docs-utils.ts— newflattenArgs(),flattenedArgsToFlags(),resolveInputFields(),cleanTypeName()helpersdocs-generator.ts— all 8 generators acceptTypeRegistry, use flattened args, clean type names, compute required/optional fields, add--no-ttydocstable-command-generator.ts— exportedgetFieldsWithDefaults()andresolveInnerInputType()generate.ts— threadscustomOperations.typeRegistryto CLI docs calls; merges registries for multi-targetReview & Testing Checklist for Human
view-grant,user,database) to confirm that fields marked as optional truly have backend defaults and won't cause create failures if omitted. The heuristic treats all nullable fields in the inner input type as having defaults — verify this matches PostGraphile's actual behavior.getFieldsWithDefaults()marks any field withtype.kind !== 'NON_NULL'as having a default. Verify that PostGraphile never uses nullable input fields for truly-required-without-defaults fields that would fail at runtime if omitted.clientMutationIdnoise: Every flattened INPUT_OBJECT now shows--input.clientMutationIdas the first flag in usage/examples. This is technically correct but clutters docs since most users never pass it. Consider whetherclientMutationIdshould be filtered out inflattenArgs().cleanTypeNameprefix stripping: The function strips the exact string"ConstructiveInternalType"— verify no type names exist where this prefix is legitimate and should be preserved. Grep generated output for any unexpected type name results.set-and-commitwith 8 fields) produce very long single-line usage strings. Check if this is acceptable for agent consumption.pnpm run generatein constructive-cli after merge to confirm the regenerated output matches expectations against the latest schema.Notes
ConstructiveInternalTypenames or complex backend defaults (example schema doesn't use custom scalars or many nullable create fields), so the new behaviors are verified primarily by inspecting regenerated output.--input.emailetc.), clean type names, and correct required/optional handling requires a running backend to verify. CI checks compile/lint only.